package com.saichuang.chapter06;

import java.util.Scanner;

/**
 * 验证用户登录信息
 */

public class ZuoYe3 {
    public static void main(String[] args) {
        String sum1;//用户名
        String sum2;//密码
        int i;
        Scanner scanner = new Scanner(System.in);
        for (i = 3; i > 0; i -= 1) {
            System.out.print("请输入用户名:");
            sum1 = scanner.next();
            if (!sum1.equals("jim")) {//判断用户名是否正确
                System.out.print("输入错误!您还有" + (i - 1) + "次机会!\n");
                continue;
            } else {
//                System.out.print("输入错误!您还有" + (i - 1) + "次机会!\n");
//                continue;
            }
            System.out.print("请输入密码:");
            sum2 = scanner.next();
            if (!sum2.equals("123456")) {//判断密码是否正确
                System.out.print("输入错误!您还有" + (i - 1) + "次机会!\n");
                continue;
            } else {
//                System.out.print("输入错误!您还有" + (i - 1) + "次机会!\n");
//                continue;
            }


            System.out.println("欢迎登录MyShopping系统");
            break;
        }
        if (i == 0) {
            System.out.println("\n对不起,您3次均输入错误!");

        }
    }
}
